<%--
  Created by IntelliJ IDEA.
  User: Lanan
  Date: 2017/12/18 0018
  Time: 21:02
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/commons/global.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <%--<%@ include file="/commons/basejs.jsp" %>--%>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>用户账户信息修改</title>
</head>
<body>
<style>
    table td{
         font:100% arial,helvetica,sans-serif;
         /*text-align: center;*/
         height:20px;
         border:1px solid #e0e0e0;
         padding-left:5px;
         border: 1px solid #e0e0e0;
     }
    .td1{
        width: 80px;
        /*background-color: rgb(242,242,242);*/
    }
</style>
<form id="update_user_account_form" method="post">
    <table align="center" width="100%" style="margin-top: 20px" cellpadding="4">
        <input type="hidden" name="id" value="${userAccount.id}"/>
        <input type="hidden" name="userId" value="${userAccount.userId}"/>
        <td class="td" align="right" width="40%"><lable for="userID">用户:</lable></td>
        <td width="60%">
            <label>${userAccount.phone}:${userAccount.name}</label>
        </td>
        <tr>
            <td class="td" align="right" width="40%"><lable for="type">账户类型:</lable></td>
            <td  width="60%">
                <select id="update_type"  class="easyui-combobox" name="type" data-options="required:true,panelHeight:'auto',editable:false" style="width:160px;">
                    <option value="0">银行卡</option>
                    <option value="1">支付宝</option>
                    <option value="2">微信</option>
                </select>
            </td>
        </tr>
        <tr id="bank_account_update_td">
            <td  class="td" align="right" width="40%"><lable for="bankAccount">银行账号:</lable></td>
            <td  width="60%">
                <input id="bank_update_account" name="bankAccount" class="easyui-numberbox" data-options="missingMessage:'请输入银行卡号', validType:'number', required:true" style="width:150px;"/>
            </td>
        </tr>
        <tr id="wechat_account_update_td">
            <td  class="td" align="right" width="40%"><lable for="name">微信账号:</lable></td>
            <td  width="60%">
                <input id="wechat_update_account" name="wechatAccount" class="easyui-validatebox" data-options="missingMessage:'请输入微信账号', required:true" style="width:150px;"/>
            </td>
        </tr>
        <tr id="ali_account_update_td">
            <td  class="td" align="right" width="40%"><lable for="aliAccount">支付宝账号:</lable></td>
            <td  width="60%">
                <input id="ali_update_account" name="aliAccount" class="easyui-validatebox" data-options="missingMessage:'请输入支付宝账号', required:true" style="width:150px;"/>
            </td>
        </tr>
        <tr id="bank_name_update_td">
            <td  class="td" align="right" width="40%"><lable for="name">银行名称:</lable></td>
            <td  width="60%">
                <input id="bank_update_name" name="bankName" class="easyui-validatebox" data-options="missingMessage:'请输入银行名称', required:true" style="width:150px;"/>
            </td>
        </tr>
        <tr id="bank_opening_update_id">
            <td class="td" align="right" width="40%"><lable for="name">开户行信息:</lable></td>
            <td width="60%">
                <textarea id="bank_update_opening" name="bankOpening" class="easyui-validatebox" data-options="missingMessage:'请输入开户行信息',required:true"></textarea>
            </td>
        </tr>
        <tr>
            <td class="td" align="right" width="40%"><lable for="def">是否设为默认:</lable></td>
            <td width="60%">
                <select id="update_adef" class="easyui-combobox" name="def" data-options="required:true,panelHeight:'auto',editable:false" style="width:160px;">
                    <option value="0">否</option>
                    <option value="1">是</option>
                </select>
            </td>
        </tr>
    </table>

    <div style="margin-top: 20px;text-align: center">
        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-save'", onclick="updateUserAccount()">提交</a>
        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'", onclick="$('#user_acount_update_dialog').dialog('close')">取消</a>
    </div>
</form>

<script type="text/javascript">

    function updateUserAccount() {
        var msg = "修改";
        var url = "/user/account/update.do";

        lananUpdateOrInsert(msg, url, "update_user_account_form", "user_acount_update_dialog", "user_account")

//        $.messager.progress();
//        $("#update_user_account_form").form("submit",{
//            url:url,
//            onSubmit:function(){
//                var valid = $(this).form("validate");
//                if (!valid) {
//                    $.messager.progress("close");
//                }
//                return valid;
//            },
//            success:function(data){
//                data=$.parseJSON(data);
//                $.messager.progress("close");
//                if(data.success){
//                    $("#user_acount_update_dialog").dialog("close");
//                    $.messager.show({
//                        title: msg + "成功",msg: msg + "成功!",
//                        timeout:600,style:"left:30%;top:10%",
//                        showType:"fade"
//                    });
//                    $("#user_account").datagrid("reload");
//                    $('#user_account').datagrid('clearSelections');
//                }else{
//                    $.messager.alert(msg + "失败", data.msg,"error");
//                }
//            },
//            error:function () {
//                $.messager.progress("close");
//                $.messager.alert("操作失败", "服务器连接失败!","error");
//            }
//        });
    }


    $(function () {
        var type = ${userAccount.type};
        $("#update_type").val(type);
        selectTypeHandel(type);
        $("#update_adef").val("${userAccount.def}");

        $("#update_type").combobox({
            onSelect:function () {
                var select = $("#update_type").combobox('getValue')
                selectTypeHandel(select)
            }
        })

    })

    function selectTypeHandel(type) {
        if (type == '0') {
            $("#bank_name_update_td").show();
            $("#bank_opening_update_id").show();
            $("#bank_account_update_td").show();
            $("#wechat_account_update_td").hide();
            $("#ali_account_update_td").hide();

            $("#bank_update_account").val("${userAccount.bankAccount}");$('#bank_update_account').numberbox({ required: true });
            $("#bank_update_name").val("${userAccount.bankName}");$('#bank_update_name').validatebox({ required: true });
            $("#bank_update_opening").val("${userAccount.bankOpening}");$('#bank_update_opening').validatebox({ required: true });
            $("#wechat_update_account").val("");$('#wechat_update_account').validatebox({ required: false });
            $("#ali_update_account").val("");$('#ali_update_account').validatebox({ required: false });
        } else {
            $("#bank_name_update_td").hide();
            $("#bank_opening_update_id").hide();
            $("#bank_account_update_td").hide();
            $("#bank_update_account").val("");$('#bank_update_account').numberbox({ required: false });
            $("#bank_update_name").val("");$('#bank_update_name').validatebox({ required: false });
            $("#bank_update_opening").val("");$('#bank_update_opening').validatebox({ required: false });
            $("#bank_update_account").numberbox("setValue", "");
            if (type == '1') {
                // 支付宝
                $("#ali_account_update_td").show();
                $("#wechat_account_update_td").hide();
                $("#ali_update_account").val("${userAccount.aliAccount}");$('#ali_update_account').validatebox({ required: true });
                $("#wechat_update_account").val("");$('#wechat_update_account').validatebox({ required: false });
            } else {
                // 微信
                $("#wechat_account_update_td").show();
                $("#ali_account_update_td").hide();
                $("#wechat_update_account").val("${userAccount.wechatAccount}");$('#wechat_update_account').validatebox({ required: true });
                $("#ali_update_account").val("");$('#ali_update_account').validatebox({ required: false });
            }
        }
    }
</script>

</body>
</html>
